package br.perfiman.dao;

import java.util.List;

import javax.ejb.Local;

import br.perfiman.model.AbstractEntity;

/**
 * Interface for the PerFiMan's Persistence Services
 *
 * @author Wagner Costa
 * @since 27/12/2007
 * @version 1.0
 *
 * @param <Entity>
 */
@Local
public interface AbstractDAOService<Entity extends AbstractEntity>{

	/**
	 * Insert a new entity to the database
	 *
	 * @author Wagner Costa
	 * @since 27/12/2007
	 * @version 1.0
	 * @param entity
	 * @return
	 * @throws Exception
	 */
	Entity insert(Entity entity) throws Exception;

	/**
	 * Update an existing entity in the database
	 *
	 * @author Wagner Costa
	 * @since 27/12/2007
	 * @version 1.0
	 * @param entity
	 * @return
	 * @throws Exception
	 */
	Entity update(Entity entity) throws Exception;

	/**
	 * Remove a entity from the database
	 *
	 * @author Wagner Costa
	 * @since 27/12/2007
	 * @version 1.0
	 * @param entity
	 * @throws Exception
	 */
	void remove(Entity entity) throws Exception;

	/**
	 * Get a entity from the database using the entity's id (AbstractEntity.getEntityId())
	 *
	 * @author Wagner Costa
	 * @since 27/12/2007
	 * @version 1.0
	 * @param id
	 * @return
	 * @throws Exception
	 */
	Entity retrieveById(Object id) throws Exception;

	/**
	 * Retrieve all entitys at the database
	 *
	 * @author Wagner Costa
	 * @since 27/12/2007
	 * @version 1.0
	 * @return
	 * @throws Exception
	 */
	List<Entity> retrieveAll() throws Exception;
}
